GtkPlacesSidebar: Don't update bookmark if cancelled
authorRoss Lagerwall <rosslagerwall@gmail.com>
Thu, 11 Sep 2014 22:25:24 +0000 (23:25 +0100)
committerRoss Lagerwall <rosslagerwall@gmail.com>
Fri, 12 Sep 2014 07:08:09 +0000 (08:08 +0100)
If the query fails because it has been cancelled, it means that
dispose() has been called, so don't try and update anything.

This fixes a segfault with Nautilus in certain situations.

https://bugzilla.gnome.org/show_bug.cgi?id=736512

gtk/gtkplacessidebar.c

index 3b92ca1329e6c63de9a64c687778515e7fc693df..8b545f5103001353021723746f7abd1c743d560b 100644 (file)
@@ -838,13 +838,16 @@ on_bookmark_query_info_complete (GObject *source,
   BookmarkQueryClosure *clos = data;
   GtkPlacesSidebar *sidebar = clos->sidebar;
   GFile *root = G_FILE (source);
+  GError *error = NULL;
   GFileInfo *info;
   gchar *bookmark_name;
   gchar *mount_uri;
   gchar *tooltip;
   GIcon *icon;
 
-  info = g_file_query_info_finish (root, result, NULL);
+  info = g_file_query_info_finish (root, result, &error);
+  if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+    goto out;
 
   bookmark_name = _gtk_bookmarks_manager_get_bookmark_label (sidebar->bookmarks_manager, root);
   if (bookmark_name == NULL && info != NULL)
@@ -880,6 +883,7 @@ on_bookmark_query_info_complete (GObject *source,
 
 out:
   g_clear_object (&info);
+  g_clear_error (&error);
   g_slice_free (BookmarkQueryClosure, clos);
 }